exports.GAStorageManager = Core.Class.singleton({

    classname: 'GAStorageManager',

    initialize: function() {
 
        this._storage = new Storage.KeyValue();
    },

    sharedStorageManager: function()
    {
    	return this;
    },

    setItem: function(key, value, callback)
    {
    	this._cb = callback;
        if(isValidString(key))
        {
        	if(callback != undefined && callback != null)
        	{
        		this._storage.setItem(key, value, this._callBack.bind(this));      		
        	}
        	else
        	{
            		this._storage.setItem(key, value, function(error, key) {});
        	}
        }
        else
        {
            console.log("Invalid key or object for GAStorageManager setItem.");
        }
    },
    
    _callBack: function(error, key)
    {
    	console.log('Logger: _callBack called for key = '+key);
    	if(this._cb != undefined && this._cb != null)
    	{
    		this._cb(error, key);
    	}
    },

    removeItem: function(item) {
        if(isValidObject(item))
        {
            this.setItem(item, null);
        }
        else
        {
            GALogger.log("Invalid key or object for GAStorageManager removeItem.");
        }
    },
    getItem : function(key,callback) {
        if(isValidString(key))
        {
            this._storage.getItem(key,callback,true);
        }
        else
        {
            GALogger.log("Invalid key or object for GAStorageManager getItem.");
        }
    },
    destroy : function(){
    	this._storage.destroy();
    }
	
});
